﻿using System;

namespace BfLib.Maths
{
    public static class MathLib
    {
        public static int GetPollCount(int num1, int num2, int step)
        {
            int diff  = (num2 - num1) + 1;
            int excess = diff % step;
            if (excess == 0)
                return (diff / step) + 1;
            else
                return ((diff - excess) / step) + 1;
        }

        public static int GetPollCount(int num1, int num2, int step, int firstPollOffset)
        {
            num1 += firstPollOffset;
            return GetPollCount(num1, num2, step);
        }

        public static int[] GetPolls(int num1, int num2, int step)
        {
            int pollCount = GetPollCount(num1, num2, step);
            int[] polls = new int[pollCount];
            int pollIndex = 0;
            for (int i = num1; i <= num2; i += step)
            {
                polls[pollIndex] = i;
                pollIndex++;
            }
            return polls;
        }

        public static int[] GetPolls(int num1, int num2, int step, int firstPollOffset)
        {
            num1 += firstPollOffset;
            return GetPolls(num1, num2, step);
        }
    }
}
